40823129

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • 個人簡介
  • supplement
    • DroidCam  teaching
  • stage1-ag7
    • W1
    • W2
    • W3
    • W4
  • stage2-ag7
    • W5
    • W6
    • W7
      • coppliasim 模擬
      • Heroku
  • stage3-ag6
    • W10
      • task1
      • task2
    • W11
    • W13
      • Robodk
      • gogs
    • W14-W15
    • W16
      • Onshape 零組件繪製
      • CoppeliaSim 4.1.0 MTB robot
      • MTB_robot add suction pad
      • 逆向運動學函式
      • Python remote API 逆向運動學函式
    • W17
      • Basket control program
      • Program introduction and purpose
      • MTB robot controls the pick and place of the ball
    • W18
CoppeliaSim 4.1.0 MTB robot << Previous Next >> 逆向運動學函式

MTB_robot add suction pad

W16_exam

影片:

主程式:

function sysCall_init()
    -- do some initialization here
     axis1=sim.getObjectHandle('MTB_axis1')
     axis1=sim.getObjectHandle('MTB_axis2')
     axis3=sim.getObjectHandle('MTB_axis3')
     axis4=sim.getObjectHandle('MTB_axis4')
     suctionPad=sim.getObjectHandle('suctionPad')       
     rotation1 = 0
     distance3 = 0
      
     deg = math.pi/180
     --sim.sJointTargetVelocity(joint,5.5)
      
      
     
      
 
end
 
function sysCall_actuation()
 calibration = 0.0042
 message,auxiliaryData=sim.getSimulatorMessage()
 if (message==sim.message_keypress) then
      print(auxiliaryData[1])--key
      if (auxiliaryData[1]==string.byte(' ')) then
      end
      if (auxiliaryData[1]==97) then--a
      rotation1 = rotation1 + 5*deg
      sim.setJointPosition(axis1, rotation1)
      end
      if (auxiliaryData[1]==100) then --d
      rotation1 = rotation1 - 5*deg
      sim.setJointPosition(axis1, rotation1)
      end
      if (auxiliaryData[1]==119) then --s
      distance3 = distance3 + 0.01 + calibration
      sim.setJointPosition(axis3, distance3)
      end
      if (auxiliaryData[1]==115) then --w
      distance3 = distance3 - 0.01 - calibration
      sim.setJointPosition(axis3, distance3)
      end
       if (auxiliaryData[1]==112) then --p activate the suction pad
sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','true')
      end -- if p
        --按p可以吸取物體
      if (auxiliaryData[1]==113) then --q deactivate the suction pad
sim.setScriptSimulationParameter(sim.getScriptAssociatedWithObject(suctionPad),'active','false')
      end -- if q
        --按q可以放開物體
      
 end   
 
 
end
function sysCall_sensing()
    -- put your sensing code here
end
 
function sysCall_cleanup()
    -- do some clean-up here
end
 
-- See the user manual or the available code snippets for additional callback functions and details


CoppeliaSim 4.1.0 MTB robot << Previous Next >> 逆向運動學函式

Copyright © All rights reserved | This template is made with by Colorlib